<%@ page import="gfo.Match" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'match.label', default: 'Match')}"/>
    <title><g:message code="default.show.label" args="[entityName]"/></title>
</head>

<body>

<div class="body">
    <h1><g:message code="default.show.label" args="[entityName]"/>
        <span class="menuButton"><g:link class="create" action="create">New Match</g:link></span></h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <div>
        <table>
            <tbody>

            <tr class="prop">
                <td colspan="2" class="tourn"><g:link controller="tournament" action="show"
                    id="${matchInstance?.tournament?.id}">${matchInstance?.tournament?.name.encodeAsHTML()}</g:link></td>
            </tr>

            <tr class="prop">
                <g:each in="${matchInstance.players}" var="ms">
                     <td valign="top" style="text-align: left;" id="${ms.winner? 'matchWinner':'value'}">
                          <g:link controller="player" action="show"
                                  id="${ms.player.id}">${ms?.player.fullName.encodeAsHTML()}</g:link></td>
                </g:each>
            </tr>

            <tr class="prop">
                <g:each in="${matchInstance.players}" var="ms">
                     <td valign="top" style="text-align: left;" id="${ms.winner? 'matchWinner':'value'}">
                          <g:link controller="fighter" action="show"
                                  id="${ms.character?.id}">${ms?.character?.name.encodeAsHTML()}</g:link></td>
                </g:each>
            </tr>

            <tr class="prop">
                <td colspan="2" valign="top" class="tourn"><g:link controller="stage" action="show"
                    id="${matchInstance?.stage?.id}">${matchInstance?.stage?.name.encodeAsHTML()}</g:link></td>
            </tr>

            <tr class="prop">
                <td colspan="2" valign="top" class="tourn"><g:link controller="bracket" action="show"
                    id="${matchInstance?.bracket?.id}">${matchInstance?.bracket?.name.encodeAsHTML()}</g:link></td>
            </tr>

            </tbody>
        </table>
    </div>

    <div class="buttons">
        <g:form>
            <g:hiddenField name="id" value="${matchInstance?.id}"/>
            <span class="button"><g:actionSubmit class="edit" action="edit"
                                                 value="${message(code: 'default.button.edit.label', default: 'Edit')}"/></span>
            <span class="button"><g:actionSubmit class="delete" action="delete"
                                                 value="${message(code: 'default.button.delete.label', default: 'Delete')}"
                                                 onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"/></span>
        </g:form>
    </div>
</div>

<g:if test="${matchInstance.vidURL}">
    <span class="matchvideo"><iframe width="560" height="315"
     src="${matchInstance.vidURL}" frameborder="0" allowfullscreen></iframe></span>
</g:if>
</body>
</html>
